package com.aiolos.wxdc.dataobject;

import com.aiolos.wxdc.enums.ProductStatusEnum;
import com.aiolos.wxdc.utils.EnumUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Entity;
import javax.persistence.Id;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 商品实体类
 */
@Entity
@Data
@DynamicInsert
@DynamicUpdate
public class ProductInfo {

    @Id
    private String productId;
    private String productName;
    private String productDescription;
    private String productIcon;
    private Integer categoryType;
    private BigDecimal productPrice;
    private Integer productStatus = ProductStatusEnum.UP.getCode();
    private Integer productStock;
    private Date createTime = new Date();
    private Date updateTime = new Date();

    //获取在架下架状态
    @JsonIgnore
    public ProductStatusEnum getProductStatusEnum(){
        return EnumUtils.getByCode(productStatus,ProductStatusEnum.class);
    }
}
